package dao.jdbc;

import java.io.IOException;
import java.sql.Connection;
import java.util.Collection;

public class JdbcDao {

	public interface JdbcDAO<T> {

		int save(Connection con, T data) throws IOException;

		int delete(Connection con, T data) throws IOException;

		T findById(Connection con, Long id) throws IOException;

		Collection<T> findAll(Connection con) throws IOException;

	}

	public static java.sql.Date toSqlDate(java.util.Date date) {
		return new java.sql.Date(date.getTime());
	}

	public static java.sql.Time toSqlTime(java.util.Date date) {
		return new java.sql.Time(date.getTime());
	}

	public static java.sql.Timestamp toSqlTimestamp(java.util.Date date) {
		return new java.sql.Timestamp(date.getTime());
	}

	public static java.util.Date toDate(java.sql.Date date) {
		return new java.util.Date(date.getTime());
	}

	public static java.util.Date toDate(java.sql.Time time) {
		return new java.util.Date(time.getTime());
	}

	public static java.util.Date toDate(java.sql.Timestamp timestamp) {
		return new java.util.Date(timestamp.getTime());
	}
}
